# python oop

# 定义类并创建实例

# class Student:
#     # 类实例的文档字符串
#     """ class Student """
#     pass

# xiaoming = Student()

# # print(xiaoming.__doc__)

# print(Student)
# print(xiaoming)

# class Student(object):
#     def __init__(self, obj):
#         self.__name = obj['name']
#         self.__age = obj['age']
#     def getName(self):
#         return self.__name

# obj = {
#     'name': 'xiam',
#     'age': 18
# }

# xiaoming = Student(obj)

# print(xiaoming.getName())

class Student(object):
    def __init__(self, name, gender):
        self.__name = name
        self.set_gender(gender)
    # 获取性别
    def get_gender(self):
        return self.__gender
    # 设置性别
    def set_gender(self, gender):
        if gender == 'male' or gender == 'female':
            self.__gender = gender
        else:
            self.__gender = 'male'

bart = Student('Bart', 'male')

bart.set_gender('female')
print(bart.get_gender())